import {
    MAIN_SWIPER_LIST, MAIN_SWIPERNAV_LIST, MAIN_TAG_LIST, MAIN_LINK_LIST, CATEGORY_LIST,
} from '../constent'
import axios from 'axios';
// 获取首页轮播图以及Nav导航数据
export function getswiperlistAction() {

    return dispatch => {

        axios.get('/mcp/home/queryMobileHomeInfo?portal=21&version=350&lang=zh-CN&country=CNQX&_areacode=CNQX&beCode=CNQX').then(res => {
            dispatch({
                type: MAIN_SWIPER_LIST, data: res.data.mobileHomeInfo.adsActivityInfos.AC_LOC_QX_APP_INDEX_SLIDE,

            })
                ;
            dispatch({
                type: MAIN_SWIPERNAV_LIST, data: res.data.mobileHomeInfo.diamondInfo.squareIconList
            })
        })
    }
}

// // 获取首页搜索页面数据
// export function getSearchlistAction() {

//     return dispatch => {
//         axios.get('/queryHotWord?portal=21&country=CNQX&lang=zh-CN&version=350&_areacode=CNQX&beCode=CNQX').then(res => {

//             dispatch({
//                 type: GET_SEARCH_LIST, data: res.data.hotWordList
//             })
//         })
//     }
// }
// 获取首页taglist 数据
export function getMaintaglistAction() {

    return dispatch => {

        axios.get('/mcp/queryHomeRegionInfo?portal=21&version=350&lang=zh-CN&country=CNQX&_areacode=CNQX&beCode=CNQX').then(res => {

            dispatch({
                type: MAIN_TAG_LIST, data: res.data.homeRegionInfos
            })
        })
    }
}

// 内容页数据
// export function getTitleListAction(id) {
//     return dispatch => {
//         axios.get(`/queryPrdDisplayDetailInfo?portal=21&version=350&lang=zh-CN&country=CNQX&_areacode=CNQX&beCode=CNQX&item_id=${id}&sbomCode=8086110027003&productId=${id}`).then(res => {
//             dispatch({
//                 type: TITLE_CART_LIST, data: res.data
//             })
//             // dispatch({
//             //     type: TITLE_SWIPER_LIST, data: res.data.sbomList[0].groupPhotoList
//             // })
//         })


//     }
// }


// 获取首页like数据
export function getYOULieklistAction() {

    return dispatch => {

        axios.post('/mcp/recommend/getRecommend', { "portal": 21, "version": 350, "lang": "zh-CN", "country": "CNQX", "_areacode": "CNQX", "beCode": "CNQX", "isRecommended": false, "pageSize": 20, "tid": "aee463fd87ad984397881ce8e73878b7", "pageNum": 1, "sceneId": "1,1,1,1801" }).then(res => {

            dispatch({
                type: MAIN_LINK_LIST, data: res.data.productList
            })
        })
    }
}

// 分类页导航数据
export function getCategoryListAction() {
    return dispatch => {
        axios.get('/mcp/getCategoryInfo?portal=21&version=350&lang=zh-CN&country=CNQX&_areacode=CNQX&beCode=CNQX&categoryId=798').then(res => {
            dispatch({
                type: CATEGORY_LIST, data: res.data,
            })
            // ;
            // dispatch({
            //     type: CATEGORY_RIGHT_LIST, data: res.data[0].subCategorys
            // })
        })
    }
}


// 全部商品
// export function getAllListAction() {
//     return dispatch => {

//         axios.get('/getCategoryPrdList?portal=21&version=350&lang=zh-CN&country=CNQX&_areacode=CNQX&beCode=CNQX&cid=98&pageNumber=1&pagesize=20&sortField=default&sortType=desc&cidLevel=1').then(res => {

//             dispatch({
//                 type: GET_ALLLIST_LIST, data: res.data.cidPrdMap[98]
//             })
//             dispatch({
//                 type: GET_ALLLIST_TOTAL, data: res.data.totalPage
//             })
//         })
//     }
// }

